# !/usr/bin/env python
# coding=utf-8
# @Time    : 2018/8/7 12:08
# @Author  : 6imensiva
# @Site    : https://gitee.com/dimensiva/rpc_dao.git
# @File    : customer_dao.py
# @Software: PyCharm
# @Version: 2.7.5
from . import Session
from db.models import TCustomerInfo
from py3_utils import my_sqlalchemy
from sqlalchemy import and_


def add_customer_info(info):
	return my_sqlalchemy.common_insert(Session(), info, TCustomerInfo)


def get_customer_list(owner_id):
	session = Session()
	return session.query(TCustomerInfo).filter(owner_id==owner_id).all()


def get_customer_info(owner_id, mobile, doc_code, customer_name):
	session = Session()
	return session.query(TCustomerInfo).filter(and_(owner_id==owner_id),
	                                           and_(mobile==mobile),
	                                           and_(doc_code==doc_code),
	                                           and_(customer_name==customer_name)).first()
